package org.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.dao.IInfoDao;
import org.util.SqlUtil;

public class InfoDao implements IInfoDao{
	public boolean queryOrderidExits(int orderid) {
		SqlUtil su=new SqlUtil();
		String sql="select count(1) from wuliutable where orderid='"+orderid+"'";
		ResultSet rs = su.queryUtil(sql);
			try {
				if(rs.next()){
					if(Integer.parseInt(rs.getString(1))>0){
							return true;
					}
				}
			} catch (NumberFormatException | SQLException e) {
				e.printStackTrace();
			}
			return false;
	}

	public List<String> queryAllWuLiuMessage(int orderid){
				List<String>  messages =new ArrayList<>();
				SqlUtil su=new SqlUtil();
				String sql ="select * from wuliutable where orderid="+orderid;
				ResultSet rs=su.queryUtil(sql);
				try {
					while(rs.next()){
						String message = rs.getString(2);
						messages.add(message);
					}
				} catch (SQLException e) {
					e.printStackTrace();
				}catch(Exception e){
					e.printStackTrace();
				}
				return messages;
			}

	@Override
	public void AddwuliuInfo(int orderid, String info) {
		String sql="insert into wuliutable values("+orderid+",'"+info+"')";
		SqlUtil su=new SqlUtil();
		int i = su.updateUtil(sql);	
	}	
}

